package org.mozhu.mboot.core.data.support;

import org.mozhu.mboot.core.data.IBaseService;
import org.mozhu.mboot.core.data.entity.IEntity;
import org.mozhu.mboot.core.data.entity.Treeable;
import org.mozhu.mboot.core.data.filter.SearchFilter;
import org.springframework.data.domain.Pageable;

import java.io.Serializable;
import java.util.List;
import java.util.Set;

public interface IBaseTreeableService<M extends IEntity<ID> & Treeable<ID>, ID extends Serializable> extends IBaseService<M, ID> {

	void deleteSelfAndChild(M m);

	void deleteSelfAndChild(List<M> mList);

	void appendChild(M parent, M child);

	int nextWeight(ID id);

	void move(M source, M target, String moveType);

	Set<String> findNames(List<SearchFilter> searchFilters, Pageable pageable, String name, ID excludeId);

	List<M> findChildren(List<M> parents, List<SearchFilter> searchFilter);

	List<M> findChildrenByParentIds(List<ID> parentIds, List<SearchFilter> searchFilter);

	List<M> findChildrenByParentIds(List<ID> parentIds);

	List<M> sort(List<M> ms);

	List<M> findAllByName(List<SearchFilter> searchFilters, M excludeM);
	
	List<M> findAllWithSort(List<SearchFilter> searchFilters);

	List<M> findRootAndChild(List<SearchFilter> searchFilter);

	List<M> findRootAndChild();

	Set<ID> findAncestorIds(Iterable<ID> currentIds);

	Set<ID> findAncestorIds(ID currentId);

	List<M> findAncestor(String parentIds);

	List<SearchFilter> buildExcludeFilter(M excludeM);

	List<ZTree<ID>> convertToZtreeList(List<M> models, boolean open, boolean onlySelectLeaf);

	ZTree<ID> convertToZtree(M m, boolean open, boolean onlyCheckLeaf);

}
